home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PASCALL / TEMPJUNK / FORMGRPH.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-20  |  2KB  |  91 lines

  1. program formgrph;
  2. uses
  3.      crt,graph;
  4. const
  5.      pause:word=0;
  6.  
  7. procedure setupgraph;
  8. var
  9.      graphdriver,graphmode:integer;
  10. begin
  11.      graphdriver:=mcga;
  12.      graphmode:=mcgahi;
  13.      initgraph(graphdriver,graphmode,'c:\tp\bgi');
  14.      if graphresult<>grOk then halt;
  15.      cleardevice;
  16. end;
  17.  
  18. procedure done;
  19. begin
  20.      restorecrtmode;
  21.      halt;
  22. end;
  23.  
  24. procedure paint(var t,tmax:longint;  var  xsize,ysize,dertx,derty:real);
  25. var
  26.     i:longint;
  27.  
  28.  
  29.  function yfunc(csize:real;t:longint):integer;
  30.  var
  31.       temp:real;
  32.  begin
  33.       temp:=trunc(csize*sin(t/100));
  34.       yfunc:=round(temp);
  35.  end;
  36.  
  37.  function xfunc(csize:real;t:longint):integer;
  38.  var
  39.       temp:real;
  40.  begin
  41.       temp:=trunc(csize*cos(t/100));
  42.       xfunc:=round(temp);
  43.  end;
  44.  
  45. begin
  46.      for i:= t to t+tmax do
  47.      begin
  48.           putpixel(xfunc(xsize,i)+320,yfunc(ysize,i)+240,white);
  49.           xsize:=xsize+dertx;     ysize:=ysize+derty;
  50.           if keypressed then done;
  51.      end;
  52.      t:=t+tmax;
  53. end;
  54.  
  55. procedure setupfornext(var tmax:longint;  var OnesizeforX,OnesizeforY,AnothersizforX,AnothersizeforY,dertx,derty:real);
  56. begin
  57.      tmax:=random(628);
  58.      OnesizeforX:=random(320);     OnesizeforY:=random(240);
  59.      dertx:=(OnesizeforX-AnothersizeforY)/tmax;     derty:=(OnesizeforY-AnothersizeforY)/tmax;
  60. end;
  61.  
  62.  
  63.  
  64.  
  65. procedure control(tmax:longint;  x1size,y1size:real);
  66. var
  67.      t:longint;
  68.      xsize,ysize:real;
  69.      x2size,y2size:real;
  70.      dertx,derty:real;
  71. begin
  72.      t:=0;
  73.      xsize:=0; ysize:=0;
  74.      setupgraph;
  75.      repeat
  76.           setupfornext(tmax,x2size,y2size,x1size,y1size,dertx,derty);
  77.           paint(t,tmax,xsize,ysize,dertx,derty);
  78. {          delay(pause);}
  79.           setupfornext(tmax,x1size,y1size,x2size,y2size,dertx,derty);
  80.           paint(t,tmax,xsize,ysize,dertx,derty);
  81. {          pause:=random(500);}
  82.      until keypressed;
  83.      done;
  84. end;
  85.  
  86.  
  87. begin
  88.      randomize;
  89.      control(random(628),random(320),random(240));
  90. end.
  91.